package http

import (
	"gitee.com/legend9999/publisher/conf"
	"gitee.com/legend9999/publisher/modle"
	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
)

func newHTMLData(c *gin.Context, data interface{}) map[string]interface{} {
	return map[string]interface{}{
		"title": conf.SysConf.Get("app.name"),
		"ctx":   data,
		"user":  GetSessionUser(c),
		"form":  c.Request.Form,
	}
}

func GetSessionUser(c *gin.Context) *modle.User {
	session := sessions.Default(c)
	user := session.Get(SessionKey)
	return user.(*modle.User)
}
